﻿using Core.DataAccess.Model;
using Core.DataAccess.Model.iTool.Gateway;
using Core.Framework;
using HandlerContextOptions;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;

namespace Environment.Interfaces
{
    public interface INodeService
    {

        Task<bool> AddNode(string ip);
        Task<List<Node>> GetNodes();

        /// <summary>
        /// 更新主机状态
        /// </summary>
        /// <returns></returns>
        Task ModifyStatus(string ip, LinuxSystemStatus status);

        /// <summary>
        /// 上报信息
        /// </summary>
        /// <returns></returns>
        Task Reporting(string ip, LinuxProcessStatus status);

        /// <summary>
        /// 停止
        /// </summary>
        /// <param name="ip"></param>
        /// <returns></returns>
        Task Stoped(string ip);
        Task UpdateServiceStatus(string ip, ProcessStatusEnum processStatus);
        Task UpdateClientStatus(string ip, ProcessStatusEnum processStatus);

        Task<List<ServiceInstance>> GetInstances(string ip);
        Task<List<ServiceInstance>> GetAllInstances();

        Task<List<ServiceInstance>> GetAllInstancesOfStorageAndConnector();

        Task<List<Node>> GetNodes(Pagination pagination);

        /// <summary>
        /// 执行命令
        /// </summary>
        /// <returns></returns>
        Task<(bool, string)> ExcuterCommand(string ip, string cmd);

        Task<(bool, string)> ExcuterCommand(string ip, string cmd, string dbType, int port, string pwd);

        /// <summary>
        /// 获取指定Docker容器状态
        /// </summary>
        /// <param name="ip"></param>
        /// <param name="container"></param>
        /// <returns></returns>
        Task<LinuxProcessStatus> ExcuterGetDokcerStatusByContainer(string ip, string container);

        /// <summary>
        /// 获取指定进程状态
        /// </summary>
        /// <param name="ip"></param>
        /// <param name="processName"></param>
        /// <returns></returns>
        Task<LinuxProcessStatus> ExcuterGetLinuxProcessStatusByProcessName(string ip, string processName);

        Task<string> PostAsync(string ip, string url, StringContent content);
    }
}
